<template>
	<div class="add-defect-info">
		<label for="configValueId">配置测试编号</label>
		<input type="text" :value="psSystemconfig.configvalueid" disabled>
		<label for="defetname">缺陷类型名称:</label>
		<input id="defetname" v-model="psSystemconfig.configvaluename" type="text" class="input-field">
		<br>
		<label for="isstart">启用状态:</label>
		<div class="radio-buttons">
			<input id="isstart-enable" v-model="psSystemconfig.isstart" value="1" type="radio" class="radio-input" name="isstart">
			<label for="isstart-enable" class="radio-label">启用</label>

			<input id="isstart-disable" type="radio" v-model="psSystemconfig.isstart" value="0" class="radio-input" name="isstart">
			<label for="isstart-disable" class="radio-label">停用</label>
		</div>

		<button class="btn btn-add" @click="addDefect">添加</button>
		<button class="btn btn-return" @click="goBack">返回</button>
	</div>
</template>

<script>
	import {getMaxConfigValueId
	,addDefetInfo} from '../../config/request.js'
	export default {
		data() {
			return{
				psSystemconfig:{
					configcode:'BUG_TYPE',
					configvalueid:'',
					configvaluename:'',
					isstart:'',
					configname:'缺陷类型'
					
				}
			}
		},
		methods: {
			addDefect() {
				alert(JSON.stringify(this.psSystemconfig))
				// 添加缺陷的逻辑
				addDefetInfo(this.psSystemconfig).then(res=>{
					console.log(res);
					if(res.code === 200){
						this.$message.success('添加成功');
					}
				}).catch(err=>{
					this.$notify.error({
						title:'请求失败',
						message:err,
						duration:1500
					})
				})
			},
			goBack() {
				// 返回的逻辑
				this.$router.push('/defetType')
			}
		},
		created() {
			//获取最大测试配置编号
			getMaxConfigValueId().then(res=>{
				console.log(res.data)
				this.psSystemconfig.configvalueid =JSON.parse(res.data.obj);
			}).catch(err=>{
				this.$notify.error({
					title:'请求失败',
					message:err,
					duration:1500
				})
			})
		}
	}
</script>

<style>
	.add-defect-info {
		width: 300px;
		margin: 20px auto;
	}

	.input-field {
		width: 100%;
		padding: 8px;
		margin-bottom: 10px;
		border: 1px solid #ccc;
		border-radius: 4px;
		box-sizing: border-box;
	}

	.radio-buttons {
		margin-bottom: 10px;
	}

	.radio